<!--黑名单企业列表-->
<template>
  <div class="container" ref="mainCon">
    <topTitle :titleText="titleText"></topTitle>
    <div class="mainCon">
      <el-row class="toolbar searchInputWidth" style="padding: 0 24px">
        <el-form :inline="true" :model="filterField" ref="searchConditions">
          <el-col :lg="8" :xl="6">
            <el-form-item label="黑名单企业" class="row-padding-bottom">
              <el-input
                v-model="filterField.name"
                placeholder="企业名称或统一社会信用代码"
                clearable
                style="width: 230px"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-form-item>
            <!-- <el-button type="primary" icon="icon iconfont iconchazhao1" @click="searchList"
                                   class="commonBtn"></el-button> -->
            <el-button
              type="primary"
              icon="icon iconfont iconchazhao1"
              @click="searchList"
              class="searchBtn"
            >
              <span>搜索</span>
            </el-button>
          </el-form-item>
          <el-form-item>
            <exportBtn
              :dataLen="tableList.length"
              :filterField="filterField"
              api="api-s/report/export_JC_CS_BACKSALARY_BLACK_COMPANY"
            ></exportBtn>
          </el-form-item>
        </el-form>
      </el-row>
      <div class="spacing"></div>
      <div
        ref="tableBox"
        :class="hiddleToolBar ? 'tableBoxCur tableBox' : 'tableBoxCur'"
      >
        <el-table
          ref="tableBox1"
          :max-height="tableHeight"
          :data="tableList"
          @sort-change="sortChange"
          v-loading="loading"
          :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
          highlight-current-row
          stripe
          style="border: 1px solid #dfe6ec"
        >
          <!-- <el-table-column prop="name" label="企业名称" align="center" :formatter=formatTd></el-table-column>  -->
          <el-table-column prop="name" label="企业名称" width="230">
            <template slot-scope="scope">
              <copyText
                :tableIndex="scope.$index"
                :copyTextName="scope.row.name"
                :columnName="'name'"
              ></copyText>
            </template>
          </el-table-column>
          <el-table-column
            prop="uscc"
            label="统一社会信用代码"
            align="center"
            :formatter="formatTd"
            min-width="230"
          ></el-table-column>
          <el-table-column prop="reason" label="列入名单事由" width="230">
            <template slot-scope="scope">
              <copyText
                :tableIndex="scope.$index"
                :copyTextName="scope.row.reason"
                :columnName="'reason'"
              ></copyText>
            </template>
          </el-table-column>
          <el-table-column
            prop="effectiveStartDate"
            label="列入日期"
            sortable="custom"
            align="center"
            min-width="180"
            :formatter="dateFormat"
          ></el-table-column>
          <el-table-column
            prop="effectiveEndDate"
            label="退出日期"
            sortable="custom"
            align="center"
            min-width="180"
            :formatter="dateFormat"
          ></el-table-column>
          <el-table-column
            prop="dataSource"
            label="数据来源"
            align="center"
            :formatter="formatTd"
            min-width="180"
          ></el-table-column>
          <el-table-column label="操作" align="left" fixed="right" width="80">
            <template slot-scope="scope">
              <el-link type="primary" @click="toDetail(scope.$index, scope.row)"
                >详情</el-link
              >
            </template>
          </el-table-column>
          <!-- 表格数据为空时，页面显示 -->
          <div slot="empty" v-show="isShow">
            <emptyTable emptyText="暂无相关信息"></emptyTable>
          </div>
        </el-table>
        <Pagination
          ref="pagination"
          @getList="getTableList"
          :filterField="filterField"
          :requestUrl="requestUrl"
        ></Pagination>
      </div>
    </div>
  </div>
</template>

<script>
import scrollTable from '@/mixin/scrollTable.js'
import moment from 'moment'
export default {
  name: 'companyBlackList',
  mixins: [scrollTable],
  data() {
    return {
      titleText: '欠薪黑名单',
      //表格数据
      tableList: [],
      requestUrl: 'api-c/company/expand/listBlackCompany',
      //搜索条件
      filterField: {
        name: '', //黑名单企业
      },
      isShow: false, //列表加载
      loading: true,
    }
  },
  created() {
    this.$nextTick(function () {
      this.$refs.pagination.getTableListData()
    })
  },
  methods: {
    getTableList(data) {
      this.tableList = data
      this.loading = false
      if (this.tableList.length < 1) {
        this.isShow = true
      }
    },
    // 搜索
    searchList() {
      this.$refs.pagination.getTableListData()
    },
    dateFormat: function (row, column, cellValue, index) {
      if (cellValue == null || cellValue === '') {
        return ''
      } else {
        return moment(cellValue).format('YYYY年MM月DD日')
      }
    },
    //跳转详情
    toDetail(index, row) {
      this.$router.push({
        path: '/home/companyProjectManage/companyBlackDetail',
        name: 'companyBlackDetail',
        query: {
          companyId: row.id,
        },
      })
      this.$store.commit('CHANGE_SLIDER_NAME', {
        oldUrl: '/home/companyProjectManage/companyBlackList',
        newUrl: this.$router.currentRoute.fullPath,
      })
    },
  },
}
</script>

<style scoped lang="less">
.topTitle {
  height: 67px;
  background-color: #e4ebf1;
  padding-left: 24px;
  font: bold 18px/67px Microsoft YaHei;
}

.mainCon {
  top: 198px;
}
@import '../../../static/css/filterArea.less';
</style>
